package com.waitingresult.number;

/**
 * @Author: WangShuai
 * @CreateTime: 2024-06-21  20:20
 * @Description:
 * @Version: 1.0
 */
public class DoubleSplitNumber {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int target = 1;
        System.err.println(split(arr, target));
    }

    public static int split(int[] arr, int target) {
        if (arr == null || arr.length == 0) {
            return 0;
        }
        int i = arr.length / 2;
        while (i > 0 && i <= arr.length) {
            if (arr[i - 1] == target) {
                return arr[i - 1];
            } else if (arr[i - 1] > target) {
                i = i / 2;
            } else {
                i = i + i / 2;
            }

        }
        return 0;
    }
}
